Repository navigation
Conversation
lxsaah
requested changes
Nov 18, 2026
| return Ok(value); | ||
| } | ||
| let value = serde_json::from_slice(bytes).map_err(|e| e.to_string())?; | ||
| self.decode_with_error(&value) |
Member
There was a problem hiding this comment.
Preserve the byte decoder’s rejection. A custom decode_slice can reject duplicate object keys. This fallback parses the same bytes into serde_json::Value, which collapses the duplicates. If the tree decoder accepts the resulting object, set_from_json_bytes commits a write the codec previously rejected.
Please map self.decode_slice(bytes) returning None directly to a generic error and apply the same change to RemoteSerialize::from_json_slice_with_error. The Serde overrides already preserve detailed errors. A regression test where the byte decoder rejects duplicate keys and the tree decoder accepts the collapsed object would cover this case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem
When a remote
record.setvalue is well-formed JSON but does not match the record's Rust type or fails validation, the write is correctly refused and the session remains healthy. The client nevertheless reports:That points at the engine or transport instead of the caller's value, which makes CLI and MCP clients retry or diagnose the wrong layer.
Root cause
The rejection lost its identity at four points:
TypedRecord::set_from_json/set_from_json_bytescollapsed every codec failure intoDbError::RuntimeError, discarding the deserializer's explanation.AimX'smap_db_errrouted every error except not-found and permission failures toRpcError::Internal.RpcErrorhad no variant for an invalid caller value, and the AimX error frame carried onlyerr, even though the envelope already reserves an optionalmsg.aimdb-clientmapped the resulting internal error to its generic engine/transport message.Fix
DbError::InvalidRecordValue { type_name, reason }, classified asDbErrorKind::Data.RemoteSerializeandJsonCodecwith default implementations, so existing manual/custom codecs remain source-compatible. The Serde-backed implementations retain the originalserde_jsonerror text.RpcError::InvalidValue(String)and map it to the AimX wire codeinvalid_valuewith the reserved optionalmsgfield.msgasCow<str>so messages containing escaped quotes or other escapes do not fail frame borrowing/decoding.aimdb-clientand the WASM bridge. CLI and MCP already renderClientError::ServerError, so they now expose the specific code and deserializer message without separate changes.aimdb-client/README.md.The change is additive on the wire. An older client that does not know
invalid_valuecontinues to decode it asinternal, and a missingmsgfalls back to a generic invalid-value explanation. Unknown future error codes retain the existinginternalfallback.Regression coverage
InvalidRecordValuewith the type name and reason.msg, a missingmsg, and unknown-code backward compatibility.record.setthroughAimxDispatchand verifies that a rejected value returnsInvalidValue, followed by a successful write on the same session.AimxConnection, writes a valid value, verifies that an invalid value returnsinvalid_valueplus the serde reason, verifies that the stored value is unchanged, and then writes a corrected value on the same connection.Validation
All commands were run with Rust 1.98.0 from
rust-toolchain.toml.make testpassed on the final commit with exit code 0. This is the repository's full workspace test target, including operational-event/build-info link checks and the std/no_std adapter and connector suites. The captured log contains 464test result: oklines and no failed test result.cargo test --quiet -p aimdb-core --features 'std,remote'log_targetstest passedcargo test --quiet -p aimdb-clientaimx_sessionintegration tests passedinstance_infotests passedpump_clienttests passedcargo test --quiet -p aimdb-core --no-default-features --features 'alloc,remote'cargo test --quiet -p aimdb-wasm-adapter --no-default-features --libmake check-toolchain-pinandmake fmt-checkpassed.make clippypassed with-D warningsacross every valid workspace feature combination, including core, client, CLI, MCP, WebSocket, UDS, serial, TCP, MQTT, KNX, Zenoh, Embassy, the WASM target, and benchmarks.cargo check -p aimdb-wasm-adapter --target wasm32-unknown-unknown --features wasm-runtimepassed.cargo check -p aimdb-cli -p aimdb-mcp -p aimdb-websocket-connector -p aimdb-uds-connectorpassed.make test-embeddedpassed, including the full no_std AimX server combinations onthumbv7em-none-eabihf.make check-no-simpassed, including the positive control that thesimbuild does pull inrand.cargo deny checkwas also run. It fails on the pre-existingRUSTSEC-2026-0543advisory forchrono 0.4.42(unmaintained, no safe upgrade available), which reaches the workspace through existingaimdb-cli,aimdb-mcp, andembassy-stm32dependencies. The summary isadvisories FAILED, bans ok, licenses ok, sources ok. This branch does not changeCargo.toml,Cargo.lock, ordeny.toml, so the PR intentionally avoids mixing an unrelated dependency migration or advisory suppression into this fix.The aggregate
make checktarget was therefore not green as a single command because itsdenyleg hits that upstream-existing advisory. Its other legs, including the WASM target check, were run directly as listed above. The separate browser test targetmake wasm-testwas not run becausewasm-pack, Chrome/Chromium, andchromedriverare unavailable in this environment.Related Issue
Fixes #454
Checklist
make check).chronoadvisory described above; the separate browser WASM tests were not run because browser tooling is absent.